# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=rofimoji
pkgver=6.2.0
pkgrel=1
pkgdesc='Emoji, unicode and general character picker for rofi and rofi-likes'
arch=('any')
url=https://github.com/fdw/rofimoji
license=('MIT')
depends=('python-configargparse')
makedepends=('git' 'python-build' 'python-installer' 'python-poetry-core')
optdepends=(
  'emoji-font: for the emojis character file'
  'nerd-fonts: for the nerd_font character file'
  'otf-font-awesome: for the fontawesome6 character file'
  'ttf-font-awesome: for the fontawesome6 character file'
  'rofi: for the X.Org selector'
  'xclip: for one of the X.Org clipboarders'
  'xsel: for one of the X.Org clipboarders'
  'xdotool: for the X.Org typer'
  'wofi: for a Wayland selector'
  'fuzzel: for a Wayland selector'
  'wl-clipboard: for the Wayland clipboarder'
  'wtype: for the Wayland typer'
)
source=("git+$url.git#tag=$pkgver")
b2sums=('SKIP')

prepare() {
  cd $pkgname
  # Remove include list https://github.com/pypa/wheel/issues/92
  sed -i '/^include =/,/]/d' pyproject.toml
}

build() {
  cd $pkgname
  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd $pkgname
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 -t "$pkgdir"/usr/share/man/man1 src/picker/docs/$pkgname.1

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/$pkgname-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
